function getCharts(id, type) {
  var myChart = echarts.init(document.getElementById(id));
  var data = [299, 501, 400, 501, 522];
  var data2 = [400, 400, 501, 501, 299, 666, 501];
  var array = [1300, 2300, 3400, 4200, 5100];
  var array1 = [6470, 6470, 6470, 6470, 6470];

  //横轴柱图1
  var options1 = {
    grid: {
      top: '6%',
      left: '8%',
      right: '8%',
      bottom: '4%',
      containLabel: true //grid 区域包含坐标轴的刻度标签。
    },
    xAxis: [{
      type: 'value',
      splitLine: {
        show: false
      },
      axisLabel: {
        show: false
      },
      axisLine: {
        show: false
      },
    }],
    yAxis: [{
      type: 'category',
      data: ['都江堰', '青城山', '武侯祠', '峨眉山', '峨眉山'],
      axisLabel: {
        margin: 16,
        textStyle: {
          color: '#9a9bae',
          fontSize: 14,
        }, //刻度标签文字颜色
      },
      axisTick: {
        show: false
      }, //取消坐标中间刻度
      axisLine: {
        show: false
      },
      splitLine: {
        show: false
      },
      silent: true,
    }],
    series: [{
      name: '月开支',
      type: 'bar',
      barGap: '-100%',
      itemStyle: {
        normal: {
          color: 'rgba(0,255,255,0.10)',
          borderColor: 'rgba(0,255,255,0.12)'
        }
      },
      data: array1
    }, {
      type: 'bar',
      barGap: '-100%',
      barWidth: '40%',
      data: array,
      itemStyle: {
        normal: {
          color: 'rgba(248,231,28,0.64)',
          borderColor: '#F8E71C'
        }
      },
      label: {
        normal: {
          show: true,
          position: 'right',
          color: '#03CEF9',
          distance: 10,
          formatter: '{c}' + '次'
        }
      },
    }]
  };
  //柱图1
  var options2 = {
    tooltip: {
      trigger: 'axis',
      axisPointer: { // 坐标轴指示器，坐标轴触发有效
        type: 'shadow'
      }
    },
    grid: {
      top: '10%',
      left: '8%',
      right: '10%',
      bottom: '17%',
      containLabel: true //grid 区域包含坐标轴的刻度标签。
    },
    xAxis: [{
      type: 'category',
      splitNumber: 4,
      data: ['遂宁市', '遂宁市', '遂宁市', '遂宁市', '遂宁市'],
      boundaryGap: true,
      axisLine: {
        show: false
      },
      axisTick: {
        show: false,
      },
      axisLabel: {
        rotate: 45,
        margin: 14,
        interval: 0,
        textStyle: {
          color: '#9a9bae',
        } //刻度标签文字颜色
      }
    }],
    yAxis: [{
      type: 'value',
      splitNumber: 4,
      axisLabel: {
        margin: 20,
        textStyle: {
          color: '#9a9bae',
        }, //刻度标签文字颜色
      },
      axisTick: {
        show: false
      }, //取消坐标中间刻度
      axisLine: {
        show: false
      },
      splitLine: {
        lineStyle: {
          color: 'rgba(0,255,255,0.19)',
        }, //坐标轴在 grid 区域中的分隔线颜色
      },
    }],
    series: [{
      name: '2016年',
      type: 'bar',
      barWidth: '40%',
      label: {
        normal: {
          show: false,
          position: 'top',
          textStyle: {
            color: '#5b83e5',
          }
        }
      },
      itemStyle: {
        normal: {
          color: 'rgba(0,255,255,0.58)',
          borderColor: '#00ffff'
        }
      },
      data: [1, 3, 4, 2, 1]
    }]
  };
  if (type == 'bar') {
    myChart.setOption(options1);
  } else if (type == 'bar-a') {
    myChart.setOption(options2);

  }
  window.onresize = myChart.resize;

}
